IPixel.Hoofer=function(game){
	this.game=game;
	this.states=[];
	this._curState=0;
};
IPixel.Hoofer.prototype.start=function(index){
	if(typeof index==='undefined'){
		index=0;
	}
	if(typeof index==='string'){
		this.game.state.start(index);
	}else if(typeof index==='number'){
		if(index<0||index>=this.states.length){
			throw new Error("parameter index out of bound");
		}
		
		this._curState=index;
		this.game.state.start(this.states[index]);	
	}
};
IPixel.Hoofer.prototype.add=function(key,state,autoStart){
	if(typeof key === 'undefined'||typeof state === 'undefined'){
		throw new Error('key or state is necessary.');
	}
	this.states.push(key);
	if(autoStart){
		this._curState=this.states.indexOf(key);
	}
	this.game.state.add(key,state,autoStart);
};
IPixel.Hoofer.prototype.next=function(){
	++this._curState;
	this.start(this._curState);
};